﻿<Window x:Class="Cronus.View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:cvm="clr-namespace:Cronus.ViewModel;assembly=CronusViewModel"
        Height="215" Width="500"
        Icon="/Cronus;component/Resources/FireCreature.ico" Closed="Window_Closed" >
    <Window.Resources>
        <Style x:Key="TaskStyle" TargetType="Button">
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsBeingTimed}" Value="true">
                    <Setter Property="Background" Value="Green" />
                    <Setter Property="Foreground" Value="White" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
        
        <cvm:ObservableTasks x:Key="TasksToDisplayResource" />
    </Window.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="30" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        
        
        <!--Stop button to stop timing totally.-->
        <Button Name="_StopButton" Content="Stop Timing"
                Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4"
                Click="StopButton_Click"/>
        
        <!--Allow the user to easily enter new task names.-->
        <TextBox Name="_NewTask" VerticalAlignment="Center"
                 Grid.Row="1" Grid.Column="0" KeyDown="NewTask_KeyDown"/>
        <Button Name="_EnterNewTask" Click="EnterNewTask_Click"
                Grid.Row="1" Grid.Column="1"
                Content="Add Task" VerticalAlignment="Center"/>
        
        <Button Content="Project Setup" VerticalAlignment="Center"
                Click="ProjectSetup_Click"
                Grid.Row="1" Grid.Column="3" />
        
        <!--Other windows to show different stats.-->
        <Button Name="_ShowTotals" Click="ShowTotals_Click"
                Content="Show Task Totals" VerticalAlignment="Center"
                Grid.Row="2" Grid.Column="0" />
        <Button Name="_ShowMonthlyTotals" Click="ShowMonthlyTotals_Click"
                Content="Show Monthly Totals" VerticalAlignment="Center"
                Grid.Row="2" Grid.Column="1" />
        <Button Name="_EditTaskBtn" Click="EditTaskBtn_Click"
                Content="Edit Tasks..." VerticalAlignment="Center"
                Grid.Row="2" Grid.Column="2" />
        <Button Name="_EditEvents" Click="EditEvents_Click"
                Content="Edit Events..." VerticalAlignment="Center"
                Grid.Row="2" Grid.Column="3" />
        
        <!--List of all tasks that could be timed.-->
        <ItemsControl Margin="10" Name="_TaskButtons"
                      ItemsSource="{Binding Source={StaticResource TasksToDisplayResource}}"
                      Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4">
            <ItemsControl.Template>
                <!--Use this to specify a border of some sort for the collection.-->
                <ControlTemplate TargetType="ItemsControl">
                    <GroupBox Header="Tasks">
                        <ScrollViewer>
                            <ItemsPresenter />
                        </ScrollViewer>
                    </GroupBox>
                </ControlTemplate>
            </ItemsControl.Template>
            
            <ItemsControl.ItemsPanel>
                <!--Use this to specify some sort of container for the items.-->
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            
            <ItemsControl.ItemTemplate>
                <!--Use this template to define what each individual item will look like.-->
                <DataTemplate x:Name="BtnTemplate">
                    <Button Width="100" Height="45" Click="TaskStart_Click"
                            HorizontalAlignment="Center" VerticalAlignment="Center"
                            Style="{StaticResource TaskStyle}">
                        <Button.Content>
                            <TextBlock Text="{Binding Path=TaskName}" TextWrapping="Wrap"
                                       VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Button.Content>
                    </Button>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
            
            <ItemsControl.ItemContainerStyle>
                <!--Use this to define the appearance of the element that contains the data
                (i.e. tool tips, margins, etc...).-->
                <Style>
                    <Setter Property="Control.Margin" Value="2.5"/>
                </Style>
            </ItemsControl.ItemContainerStyle>
        </ItemsControl>
    </Grid>
</Window>
